package com.xuxin.baby.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.UserTicketBean;
import com.xuxin.baby.utils.BaseUtils;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.10 0010
 * 学习券
 */
public class UserTicketAdapter extends BaseMultiItemQuickAdapter<UserTicketBean.ResultBean.ItemsBean, BaseViewHolder> {

    public UserTicketAdapter() {
        addItemType(0, R.layout.item_user_ticket_valid);
        addItemType(1, R.layout.item_user_ticket_invalid);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, UserTicketBean.ResultBean.ItemsBean item) {
        switch (item.getItemType()) {
            case 0:
                holder.setText(R.id.item_user_ticket_valid_name, item.getTCoupon().getTitle());
                holder.setText(R.id.item_user_ticket_valid_time, BaseUtils.getTime(item.getTCoupon().getEndTime()) + "到期");
                holder.setText(R.id.item_user_ticket_valid_rule, item.getTCoupon().getMemo());
                break;
            case 1:
                holder.setText(R.id.item_user_ticket_invalid_name, item.getTCoupon().getTitle());
                holder.setText(R.id.item_user_ticket_invalid_time, BaseUtils.getTime(item.getTCoupon().getEndTime()) + "到期");
                holder.setText(R.id.item_user_ticket_invalid_rule, item.getTCoupon().getMemo());
                break;
        }
    }
}